<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Services\AipContentCensor;

class BaiduController extends Controller
{
    protected $BaiduServices;

    public function __construct()
    {
        $this->BaiduServices = new AipContentCensor('24793510', 'lUQgysc67IP22e1XnXt8tOnO', 'G3XmgVgB6h9D3jeIm0oxEeT7H3eaGCKM');
    }

    public function contentTest()
    {
        $text1 = "共产党";
        $result = $this->BaiduServices->textCensorUserDefined($text1);


        if($result['conclusionType'] == 2)
        {
            $text = str_replace($text1, $text1,'***');
        }
        dd("原单词：" . $text1 . " ,替换后： ". $text);
    }

    public function test()
    {

    }

    public function test1()
    {

    }

    public function test2()
    {

    }
}
